package ign.agents;

import ign.behaviours.generator.Generation;
import jade.core.Agent;
import jade.core.behaviours.TickerBehaviour;
import jade.domain.DFService;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;
import jade.domain.FIPAException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Cette classe s'occupe de générer les agents.
 * @author Simon Bourigaut & Ghislain Di Paolo
 */
public class Generator extends Agent {
	private static final long serialVersionUID = 4746387788713171339L;
	TickerBehaviour generation;
	long period = 1000;

	@Override
	protected void setup(){
		
		DFAgentDescription d = new DFAgentDescription();
		d.setName(getAID());
		
		ServiceDescription sd = new ServiceDescription();
		sd.setType("Generator");
		sd.setName("generator1");
		d.addServices(sd);

		try {
			DFService.register(this, d);
		} catch (FIPAException e) {
			Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
		}
		
		/* Ajoute les behaviour de génération */
		generation = new Generation(this, period);
		
		addBehaviour(generation);
	}
	
	@Override
	protected void takeDown(){
		
	}
}
